window.__require = function e(t, n, r) {
  function s(o, u) {
    if (!n[o]) {
      if (!t[o]) {
        var b = o.split("/");
        b = b[b.length - 1];
        if (!t[b]) {
          var a = "function" == typeof __require && __require;
          if (!u && a) return a(b, !0);
          if (i) return i(b, !0);
          throw new Error("Cannot find module '" + o + "'");
        }
        o = b;
      }
      var f = n[o] = {
        exports: {}
      };
      t[o][0].call(f.exports, function(e) {
        var n = t[o][1][e];
        return s(n || e);
      }, f, f.exports, e, t, n, r);
    }
    return n[o].exports;
  }
  var i = "function" == typeof __require && __require;
  for (var o = 0; o < r.length; o++) s(r[o]);
  return s;
}({
  BtnAction: [ function(require, module, exports) {
    "use strict";
    cc._RF.push(module, "a1059MYL8tMZLH4o6dltpX+", "BtnAction");
    "use strict";
    var __extends = this && this.__extends || function() {
      var extendStatics = function(d, b) {
        extendStatics = Object.setPrototypeOf || {
          __proto__: []
        } instanceof Array && function(d, b) {
          d.__proto__ = b;
        } || function(d, b) {
          for (var p in b) Object.prototype.hasOwnProperty.call(b, p) && (d[p] = b[p]);
        };
        return extendStatics(d, b);
      };
      return function(d, b) {
        extendStatics(d, b);
        function __() {
          this.constructor = d;
        }
        d.prototype = null === b ? Object.create(b) : (__.prototype = b.prototype, new __());
      };
    }();
    var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
      var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
      if ("object" === typeof Reflect && "function" === typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
      return c > 3 && r && Object.defineProperty(target, key, r), r;
    };
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
    var BtnAction = function(_super) {
      __extends(BtnAction, _super);
      function BtnAction() {
        return null !== _super && _super.apply(this, arguments) || this;
      }
      BtnAction.prototype.init = function(title, btnId) {
        this._btnId = btnId;
        this.getComponentInChildren(cc.Label).string = title;
      };
      BtnAction.prototype.onLoad = function() {};
      BtnAction.prototype.onClick = function() {
        var parent = this.node.parent.parent;
        parent.emit("btnClick", '"' + this._btnId + '"');
      };
      BtnAction = __decorate([ ccclass ], BtnAction);
      return BtnAction;
    }(cc.Component);
    exports.default = BtnAction;
    cc._RF.pop();
  }, {} ],
  JoyStick: [ function(require, module, exports) {
    "use strict";
    cc._RF.push(module, "b8cf3ZxHWBGHZlkCq0F7o3T", "JoyStick");
    "use strict";
    var __extends = this && this.__extends || function() {
      var extendStatics = function(d, b) {
        extendStatics = Object.setPrototypeOf || {
          __proto__: []
        } instanceof Array && function(d, b) {
          d.__proto__ = b;
        } || function(d, b) {
          for (var p in b) Object.prototype.hasOwnProperty.call(b, p) && (d[p] = b[p]);
        };
        return extendStatics(d, b);
      };
      return function(d, b) {
        extendStatics(d, b);
        function __() {
          this.constructor = d;
        }
        d.prototype = null === b ? Object.create(b) : (__.prototype = b.prototype, new __());
      };
    }();
    var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
      var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
      if ("object" === typeof Reflect && "function" === typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
      return c > 3 && r && Object.defineProperty(target, key, r), r;
    };
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    var BtnAction_1 = require("./BtnAction");
    var MyWebService_1 = require("./MyWebService");
    var tvEvent_1 = require("./tvEvent");
    var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
    var JoyStick = function(_super) {
      __extends(JoyStick, _super);
      function JoyStick() {
        var _this = null !== _super && _super.apply(this, arguments) || this;
        _this.tipLabel = null;
        _this.maxR = 100;
        _this.dir = cc.v2(0, 0);
        return _this;
      }
      JoyStick.prototype.onLoad = function() {
        this.stick.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
        this.stick.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
        this.stick.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
        this.stick.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this);
        this.node.on("btnClick", this.btnClick, this);
      };
      JoyStick.prototype.onScreen = function(sc) {
        console.log("JoyStick on Screen");
        this.btns.removeAllChildren();
        for (var _i = 0, _a = sc.btns; _i < _a.length; _i++) {
          var bc = _a[_i];
          console.log("btn:", bc);
          var btn = cc.instantiate(this.btnPrefab).getComponent(BtnAction_1.default);
          btn.init(bc.label, bc.btnId);
          this.btns.addChild(btn.node);
        }
        sc.dir == tvEvent_1.tv.DirType.Portrait ? this.tipLabel.string = "\u8bf7\u7ad6\u5c4f\u64cd\u4f5c" : this.tipLabel.string = "\u8bf7\u6a2a\u5c4f\u5c4f\u64cd\u4f5c";
      };
      JoyStick.prototype.btnClick = function(btnId) {
        MyWebService_1.default.GetInstance().sendEvent(tvEvent_1.tv.EventType.BUTTON_CLICK, btnId);
      };
      JoyStick.prototype.onTouchStart = function(e) {
        this.dir.x = 0;
        this.dir.y = 0;
        this.sendDir(tvEvent_1.tv.EventType.JOYSTICK_DOWN);
      };
      JoyStick.prototype.onTouchEnd = function(e) {
        this.stick.setPosition(0, 0);
        this.dir.x = 0;
        this.dir.y = 0;
        this.sendDir(tvEvent_1.tv.EventType.JOYSTICK_UP);
      };
      JoyStick.prototype.onTouchMove = function(e) {
        var pos = this.stick.convertToNodeSpaceAR(e.getLocation());
        var len = pos.len();
        if (len > this.maxR) {
          pos.x = pos.x * this.maxR / len;
          pos.y = pos.y * this.maxR / len;
          len = this.maxR;
        }
        this.dir.x = pos.x / len;
        this.dir.y = pos.y / len;
        this.stick.setPosition(pos);
        this.sendDir(tvEvent_1.tv.EventType.JOYSTICK_MOVE);
      };
      JoyStick.prototype.sendDir = function(type) {
        MyWebService_1.default.GetInstance().sendEvent(type, this.dir.x.toFixed(2), this.dir.y.toFixed(2));
      };
      __decorate([ property(cc.Prefab) ], JoyStick.prototype, "btnPrefab", void 0);
      __decorate([ property(cc.Node) ], JoyStick.prototype, "btns", void 0);
      __decorate([ property(cc.Label) ], JoyStick.prototype, "tipLabel", void 0);
      __decorate([ property(cc.Node) ], JoyStick.prototype, "stick", void 0);
      __decorate([ property ], JoyStick.prototype, "maxR", void 0);
      JoyStick = __decorate([ ccclass ], JoyStick);
      return JoyStick;
    }(cc.Component);
    exports.default = JoyStick;
    cc._RF.pop();
  }, {
    "./BtnAction": "BtnAction",
    "./MyWebService": "MyWebService",
    "./tvEvent": "tvEvent"
  } ],
  Main: [ function(require, module, exports) {
    "use strict";
    cc._RF.push(module, "8a534HM0DJOl4If8zGJRpln", "Main");
    "use strict";
    var __extends = this && this.__extends || function() {
      var extendStatics = function(d, b) {
        extendStatics = Object.setPrototypeOf || {
          __proto__: []
        } instanceof Array && function(d, b) {
          d.__proto__ = b;
        } || function(d, b) {
          for (var p in b) Object.prototype.hasOwnProperty.call(b, p) && (d[p] = b[p]);
        };
        return extendStatics(d, b);
      };
      return function(d, b) {
        extendStatics(d, b);
        function __() {
          this.constructor = d;
        }
        d.prototype = null === b ? Object.create(b) : (__.prototype = b.prototype, new __());
      };
    }();
    var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
      var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
      if ("object" === typeof Reflect && "function" === typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
      return c > 3 && r && Object.defineProperty(target, key, r), r;
    };
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    var JoyStick_1 = require("./JoyStick");
    var MyWebService_1 = require("./MyWebService");
    var TouchPad_1 = require("./TouchPad");
    var tvEvent_1 = require("./tvEvent");
    var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
    var TOUCH_PAD = "\u89e6\u6478\u677f";
    var JOY_STICK = "\u6e38\u620f\u6746";
    var Main = function(_super) {
      __extends(Main, _super);
      function Main() {
        var _this = null !== _super && _super.apply(this, arguments) || this;
        _this.linkStatus = null;
        _this.linkBtn = null;
        _this.linkBtnLabel = null;
        _this.switchBtnLabel = null;
        _this.tipLabel = null;
        _this.joyStickNode = null;
        _this.touchNode = null;
        _this.setupDlg = null;
        _this.current = TOUCH_PAD;
        _this.params = new Map();
        return _this;
      }
      Main.prototype.onLoad = function() {
        this.checkEnv();
        this.node.on("continue", this.continueGame, this);
        this.node.on("reset", this.resetGame, this);
        MyWebService_1.default.GetInstance().on(MyWebService_1.WS_EVENT.Screen, this.onScreen, this);
      };
      Main.prototype.onDestroy = function() {
        MyWebService_1.default.GetInstance().close();
      };
      Main.prototype.onScreen = function(sc) {
        console.log("Main on screen", sc);
        if (sc.type == tvEvent_1.tv.ScreenType.TOUCH_PAD) {
          this.current == JOY_STICK && this.switchController();
          this.touchNode.getComponent(TouchPad_1.default).onScreen(sc);
        } else if (sc.type == tvEvent_1.tv.ScreenType.JOYSTICK) {
          this.current == TOUCH_PAD && this.switchController();
          this.joyStickNode.getComponent(JoyStick_1.default).onScreen(sc);
        }
      };
      Main.prototype.checkEnv = function() {
        var parentWin = window.parent.window;
        if (parentWin.fireGameEvent) {
          console.log("in Frame");
          MyWebService_1.default.GetInstance().parentWin = parentWin;
          this.linkStatus.string = "IFrame \u6d4b\u8bd5";
          this.linkBtn.active = false;
        } else {
          MyWebService_1.default.GetInstance().on(MyWebService_1.WS_EVENT.Connect, this.onWebServiceConnect, this);
          MyWebService_1.default.GetInstance().on(MyWebService_1.WS_EVENT.Disconnect, this.onWebServiceDisconnect, this);
          MyWebService_1.default.GetInstance().on(MyWebService_1.WS_EVENT.Message, this.onMessage, this);
          this.getParams();
          MyWebService_1.default.GetInstance().init();
        }
      };
      Main.prototype.onMessage = function(msg) {
        console.log("msg:", msg);
      };
      Main.prototype.onWebServiceConnect = function() {
        console.log("webService connect");
        this.linkStatus.string = "\u670d\u52a1\u5668\u5df2\u8fde\u63a5";
        this.linkBtnLabel.string = "\u65ad\u5f00";
        var role = this.params.get("role");
        if (role) {
          console.log("onConnect send role=", role);
          MyWebService_1.default.GetInstance().sendRole(role);
        }
      };
      Main.prototype.onWebServiceDisconnect = function() {
        console.log("webService disconnect");
        this.linkStatus.string = "\u670d\u52a1\u5668\u672a\u8fde\u63a5";
        this.linkBtnLabel.string = "\u8fde\u63a5";
      };
      Main.prototype.getParams = function() {
        var url = window.location.href;
        console.log("url", url);
        var p = url.split("?")[1];
        console.log("url2", url, p);
        if (!p) return;
        var paramsArray = p.split("&");
        console.log("url3", paramsArray);
        for (var i = 0; i < paramsArray.length; i++) {
          var keyValue = paramsArray[i].split("=");
          this.params.set(keyValue[0], keyValue[1]);
        }
        console.log("params", this.params);
      };
      Main.prototype.switchController = function() {
        if (this.current == JOY_STICK) {
          this.joyStickNode.active = false;
          this.touchNode.active = true;
          this.switchBtnLabel.string = JOY_STICK;
          this.current = TOUCH_PAD;
        } else {
          this.joyStickNode.active = true;
          this.touchNode.active = false;
          this.switchBtnLabel.string = TOUCH_PAD;
          this.current = JOY_STICK;
        }
      };
      Main.prototype.linkServer = function() {
        MyWebService_1.default.GetInstance().getStatus() ? MyWebService_1.default.GetInstance().close() : MyWebService_1.default.GetInstance().init();
      };
      Main.prototype.pauseDlg = function() {
        this.setupDlg.active = true;
        MyWebService_1.default.GetInstance().sendCmd(tvEvent_1.tv.CMDType.PAUSE);
      };
      Main.prototype.continueGame = function() {
        console.log("continue game");
        this.setupDlg.active = false;
        MyWebService_1.default.GetInstance().sendCmd(tvEvent_1.tv.CMDType.RESUME);
      };
      Main.prototype.resetGame = function() {
        console.log("reset game");
        this.setupDlg.active = false;
        MyWebService_1.default.GetInstance().sendCmd(tvEvent_1.tv.CMDType.RESTART);
      };
      __decorate([ property(cc.Label) ], Main.prototype, "linkStatus", void 0);
      __decorate([ property(cc.Node) ], Main.prototype, "linkBtn", void 0);
      __decorate([ property(cc.Label) ], Main.prototype, "linkBtnLabel", void 0);
      __decorate([ property(cc.Label) ], Main.prototype, "switchBtnLabel", void 0);
      __decorate([ property(cc.Label) ], Main.prototype, "tipLabel", void 0);
      __decorate([ property(cc.Node) ], Main.prototype, "joyStickNode", void 0);
      __decorate([ property(cc.Node) ], Main.prototype, "touchNode", void 0);
      __decorate([ property(cc.Node) ], Main.prototype, "setupDlg", void 0);
      Main = __decorate([ ccclass ], Main);
      return Main;
    }(cc.Component);
    exports.default = Main;
    cc._RF.pop();
  }, {
    "./JoyStick": "JoyStick",
    "./MyWebService": "MyWebService",
    "./TouchPad": "TouchPad",
    "./tvEvent": "tvEvent"
  } ],
  MyWebService: [ function(require, module, exports) {
    "use strict";
    cc._RF.push(module, "79ee2i0xfFCtoxA0SB6FeE6", "MyWebService");
    "use strict";
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.WS_EVENT = void 0;
    var tvEvent_1 = require("./tvEvent");
    var WS_EVENT;
    (function(WS_EVENT) {
      WS_EVENT["Connect"] = "Connect";
      WS_EVENT["Disconnect"] = "Disconnect";
      WS_EVENT["Message"] = "Message";
      WS_EVENT["Screen"] = "Screen";
    })(WS_EVENT = exports.WS_EVENT || (exports.WS_EVENT = {}));
    var MyWebService = function() {
      function MyWebService() {
        this.socket = null;
        this.linked = false;
        this.parentWin = null;
        this.serverIp = "192.168.31.80";
        this.target = new cc.EventTarget();
      }
      MyWebService.GetInstance = function() {
        null == MyWebService._instace && (MyWebService._instace = new MyWebService());
        return MyWebService._instace;
      };
      MyWebService.prototype.init = function() {
        var addr = "ws://" + this.serverIp + ":8080/websocket";
        this.socket = new WebSocket(addr);
        this.socket.onopen = function() {
          MyWebService.GetInstance().onConnect();
        };
        this.socket.onmessage = function(event) {
          MyWebService.GetInstance().onReceive(event);
        };
        this.socket.onclose = function() {
          MyWebService.GetInstance().onDisconnected();
        };
        this.socket.onerror = function(error) {
          console.error("WebSocket error: ", error);
        };
      };
      MyWebService.prototype.onConnect = function() {
        console.log("WebSocket connected", this);
        this.linked = true;
        this.target.emit(WS_EVENT.Connect);
      };
      MyWebService.prototype.onDisconnected = function() {
        console.log("WebSocket disconnected");
        this.linked = false;
        this.target.emit(WS_EVENT.Disconnect);
      };
      MyWebService.prototype.onReceive = function(event) {
        console.log("Received data: " + event.data);
        var s = event.data;
        if ("cmd:vibrate" === s) navigator.vibrate(200); else if (s.startsWith("msg:")) this.target.emit(WS_EVENT.Message, s.substring(4)); else if (s.startsWith("cmd:screen:")) {
          var config = s.substring(11);
          this.handleScreen(config);
        } else console.log("unknow data:" + s);
      };
      MyWebService.prototype.handleScreen = function(config) {
        console.log("screen config:", config);
        var sc = JSON.parse(config);
        this.target.emit(WS_EVENT.Screen, sc);
      };
      MyWebService.prototype.sendMessage = function(s) {
        this.linked ? this.socket.send(s) : console.error("server not connected");
      };
      MyWebService.prototype.sendKey = function(key) {
        this.sendMessage("kb:" + key);
      };
      MyWebService.prototype.sendRole = function(role) {
        this.sendMessage("role:" + role);
      };
      MyWebService.prototype.sendEvent = function(type, org_arg1, org_arg2) {
        var arg1 = org_arg1;
        var arg2 = org_arg2;
        if (this.parentWin) this.parentWin.fireGameEvent(type, arg1, arg2); else {
          var s = '"' + type + '"';
          if (arg1) {
            s += "," + arg1;
            arg2 && (s += "," + arg2);
          }
          this.sendMessage(s);
        }
      };
      MyWebService.prototype.sendBtn = function(btnId) {
        this.sendEvent(tvEvent_1.tv.EventType.BUTTON_CLICK, btnId);
      };
      MyWebService.prototype.sendCmd = function(cmd) {
        this.sendEvent(tvEvent_1.tv.EventType.CMD, cmd);
      };
      MyWebService.prototype.getStatus = function() {
        return this.linked;
      };
      MyWebService.prototype.close = function() {
        this.linked && this.socket.close();
      };
      MyWebService.prototype.on = function(type, callback, target) {
        this.target.on(type, callback, target);
      };
      MyWebService.prototype.once = function(type, callback, target) {
        this.target.once(type, callback, target);
      };
      MyWebService.prototype.off = function(type, callback, target) {
        this.target.off(type, callback, target);
      };
      MyWebService._instace = null;
      return MyWebService;
    }();
    exports.default = MyWebService;
    cc._RF.pop();
  }, {
    "./tvEvent": "tvEvent"
  } ],
  SetupDlg: [ function(require, module, exports) {
    "use strict";
    cc._RF.push(module, "dea7bHhR3VFTJL8ubI1INbD", "SetupDlg");
    "use strict";
    var __extends = this && this.__extends || function() {
      var extendStatics = function(d, b) {
        extendStatics = Object.setPrototypeOf || {
          __proto__: []
        } instanceof Array && function(d, b) {
          d.__proto__ = b;
        } || function(d, b) {
          for (var p in b) Object.prototype.hasOwnProperty.call(b, p) && (d[p] = b[p]);
        };
        return extendStatics(d, b);
      };
      return function(d, b) {
        extendStatics(d, b);
        function __() {
          this.constructor = d;
        }
        d.prototype = null === b ? Object.create(b) : (__.prototype = b.prototype, new __());
      };
    }();
    var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
      var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
      if ("object" === typeof Reflect && "function" === typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
      return c > 3 && r && Object.defineProperty(target, key, r), r;
    };
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
    var SetupDlg = function(_super) {
      __extends(SetupDlg, _super);
      function SetupDlg() {
        return null !== _super && _super.apply(this, arguments) || this;
      }
      SetupDlg.prototype.continueGame = function() {
        this.node.dispatchEvent(new cc.Event.EventCustom("continue", true));
      };
      SetupDlg.prototype.resetGame = function() {
        this.node.dispatchEvent(new cc.Event.EventCustom("reset", true));
      };
      SetupDlg = __decorate([ ccclass ], SetupDlg);
      return SetupDlg;
    }(cc.Component);
    exports.default = SetupDlg;
    cc._RF.pop();
  }, {} ],
  TouchPad: [ function(require, module, exports) {
    "use strict";
    cc._RF.push(module, "5942bTa8C1PR5yRIyvxIzvL", "TouchPad");
    "use strict";
    var __extends = this && this.__extends || function() {
      var extendStatics = function(d, b) {
        extendStatics = Object.setPrototypeOf || {
          __proto__: []
        } instanceof Array && function(d, b) {
          d.__proto__ = b;
        } || function(d, b) {
          for (var p in b) Object.prototype.hasOwnProperty.call(b, p) && (d[p] = b[p]);
        };
        return extendStatics(d, b);
      };
      return function(d, b) {
        extendStatics(d, b);
        function __() {
          this.constructor = d;
        }
        d.prototype = null === b ? Object.create(b) : (__.prototype = b.prototype, new __());
      };
    }();
    var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
      var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
      if ("object" === typeof Reflect && "function" === typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
      return c > 3 && r && Object.defineProperty(target, key, r), r;
    };
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    var BtnAction_1 = require("./BtnAction");
    var MyWebService_1 = require("./MyWebService");
    var tvEvent_1 = require("./tvEvent");
    var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
    var TouchPad = function(_super) {
      __extends(TouchPad, _super);
      function TouchPad() {
        var _this = null !== _super && _super.apply(this, arguments) || this;
        _this.pad = null;
        _this.redNode = null;
        _this.tipLabel = null;
        _this.LIMIT_X = 360;
        _this.LIMIT_Y = 640;
        return _this;
      }
      TouchPad.prototype.onLoad = function() {
        this.pad.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
        this.pad.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
        this.pad.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
        this.pad.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchCancel, this);
        this.node.on("btnClick", this.btnClick, this);
      };
      TouchPad.prototype.onScreen = function(sc) {
        sc.dir == tvEvent_1.tv.DirType.Portrait ? this.tipLabel.string = "\u8bf7\u7ad6\u5c4f\u64cd\u4f5c" : this.tipLabel.string = "\u8bf7\u6a2a\u5c4f\u5c4f\u64cd\u4f5c";
        this.pad.scale = sc.scale;
        this.pad.width = sc.width;
        this.pad.height = sc.height;
        this.LIMIT_X = sc.width / 2;
        this.LIMIT_Y = sc.height / 2;
        sc.btns.length > 0 ? this.btns.active = true : this.btns.active = false;
        for (var _i = 0, _a = sc.btns; _i < _a.length; _i++) {
          var bc = _a[_i];
          console.log("btn:", bc);
          var btn = cc.instantiate(this.btnPrefab).getComponent(BtnAction_1.default);
          btn.init(bc.label, bc.btnId);
          this.btns.addChild(btn.node);
        }
      };
      TouchPad.prototype.btnClick = function(btnId) {
        MyWebService_1.default.GetInstance().sendEvent(tvEvent_1.tv.EventType.BUTTON_CLICK, btnId);
      };
      TouchPad.prototype.onTouchStart = function(e) {
        this.redNode.active = true;
        var rp = this.pad.convertToNodeSpaceAR(e.getLocation());
        this.pos = this.checkRange(rp);
        this.redNode.setPosition(this.pos);
        this.sendDir(tvEvent_1.tv.EventType.TOUCH_START);
      };
      TouchPad.prototype.onTouchMove = function(e) {
        var rp = this.pad.convertToNodeSpaceAR(e.getLocation());
        this.pos = this.checkRange(rp);
        this.redNode.setPosition(this.pos);
        this.sendDir(tvEvent_1.tv.EventType.TOUCH_MOVE);
      };
      TouchPad.prototype.onTouchCancel = function(e) {
        var rp = this.pad.convertToNodeSpaceAR(e.getLocation());
        this.pos = this.checkRange(rp);
        this.redNode.active = false;
        this.sendDir(tvEvent_1.tv.EventType.TOUCH_CANCEL);
      };
      TouchPad.prototype.checkRange = function(p) {
        var p2 = cc.v2(p.x, p.y);
        p2.x > this.LIMIT_X && (p2.x = this.LIMIT_X);
        p2.x < -this.LIMIT_X && (p2.x = -this.LIMIT_X);
        p2.y > this.LIMIT_Y && (p2.y = this.LIMIT_Y);
        p2.y < -this.LIMIT_Y && (p2.y = -this.LIMIT_Y);
        return p2;
      };
      TouchPad.prototype.onTouchEnd = function(e) {
        var rp = this.pad.convertToNodeSpaceAR(e.getLocation());
        this.pos = this.checkRange(rp);
        this.redNode.active = false;
        this.sendDir(tvEvent_1.tv.EventType.TOUCH_END);
      };
      TouchPad.prototype.sendDir = function(type) {
        MyWebService_1.default.GetInstance().sendEvent(type, this.pos.x.toFixed(2), this.pos.y.toFixed(2));
      };
      __decorate([ property(cc.Prefab) ], TouchPad.prototype, "btnPrefab", void 0);
      __decorate([ property(cc.Node) ], TouchPad.prototype, "btns", void 0);
      __decorate([ property(cc.Node) ], TouchPad.prototype, "pad", void 0);
      __decorate([ property(cc.Node) ], TouchPad.prototype, "redNode", void 0);
      __decorate([ property(cc.Label) ], TouchPad.prototype, "tipLabel", void 0);
      TouchPad = __decorate([ ccclass ], TouchPad);
      return TouchPad;
    }(cc.Component);
    exports.default = TouchPad;
    cc._RF.pop();
  }, {
    "./BtnAction": "BtnAction",
    "./MyWebService": "MyWebService",
    "./tvEvent": "tvEvent"
  } ],
  tvEvent: [ function(require, module, exports) {
    "use strict";
    cc._RF.push(module, "69184jJcjhEPbVdB4iLceKc", "tvEvent");
    "use strict";
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.tv = void 0;
    var tv;
    (function(tv) {
      var EventType;
      (function(EventType) {
        EventType["JOYSTICK_DOWN"] = "JSD";
        EventType["JOYSTICK_UP"] = "JSU";
        EventType["JOYSTICK_MOVE"] = "JSM";
        EventType["BUTTON_CLICK"] = "Btn";
        EventType["CMD"] = "CMD";
        EventType["TOUCH_START"] = "THS";
        EventType["TOUCH_END"] = "THE";
        EventType["TOUCH_MOVE"] = "THM";
        EventType["TOUCH_CANCEL"] = "THC";
      })(EventType = tv.EventType || (tv.EventType = {}));
      var ButtonType;
      (function(ButtonType) {
        ButtonType["BTN_1"] = "btn_1";
        ButtonType["BTN_2"] = "btn_2";
        ButtonType["BTN_3"] = "btn_3";
        ButtonType["BTN_4"] = "btn_4";
      })(ButtonType = tv.ButtonType || (tv.ButtonType = {}));
      var CMDType;
      (function(CMDType) {
        CMDType["PAUSE"] = "pause";
        CMDType["RESUME"] = "resume";
        CMDType["RESTART"] = "restart";
      })(CMDType = tv.CMDType || (tv.CMDType = {}));
      var ScreenType;
      (function(ScreenType) {
        ScreenType["JOYSTICK"] = "js";
        ScreenType["TOUCH_PAD"] = "tp";
      })(ScreenType = tv.ScreenType || (tv.ScreenType = {}));
      var DirType;
      (function(DirType) {
        DirType["Portrait"] = "0";
        DirType["landscape"] = "1";
      })(DirType = tv.DirType || (tv.DirType = {}));
      var BtnConfig = function() {
        function BtnConfig() {}
        return BtnConfig;
      }();
      tv.BtnConfig = BtnConfig;
      var ScreenConfig = function() {
        function ScreenConfig() {}
        return ScreenConfig;
      }();
      tv.ScreenConfig = ScreenConfig;
    })(tv = exports.tv || (exports.tv = {}));
    cc._RF.pop();
  }, {} ]
}, {}, [ "BtnAction", "JoyStick", "Main", "MyWebService", "SetupDlg", "TouchPad", "tvEvent" ]);